/*
 * 文件名：NewsInfoBussinessImpl.java
 * 版权：Copyright 2007-2016 517na Tech. Co. Ltd. All Rights Reserved. 
 * 描述： NewsInfoBussinessImpl.java
 * 修改人：yanshu
 * 修改时间：2016年1月26日
 * 修改内容：新增
 */
package com.feichuang.chineseWoodCarving.business.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.better517na.javaKeyIdGenerator.DatabaseDefinition;
import com.better517na.javaKeyIdGenerator.TableDefinition;
import com.feichuang.chineseWoodCarving.business.INewsInfoBussiness;
import com.feichuang.chineseWoodCarving.dao.INewsInfoDao;
import com.feichuang.chineseWoodCarving.model.MNewsInfo;
import com.feichuang.chineseWoodCarving.model.MPagerRequestVo;
import com.feichuang.chineseWoodCarving.model.MPagerResultVo;

/**
 * TODO 新闻资讯/根雕知识.
 * <p>
 * TODO 详细描述
 * <p>
 * TODO 示例代码
 * 
 * <pre>
 * </pre>
 * 
 * @author yanshu
 */
@Service("newsInfoBussiness")
public class NewsInfoBussinessImpl extends BaseBusinessImpl implements INewsInfoBussiness {

    @Resource(name = "newsInfoDao")
    private INewsInfoDao newsInfoDao;

    /**
     * {@inheritDoc}.
     */
    @Override
    public MPagerResultVo<MNewsInfo> selectMNewsInfoForPage(MPagerRequestVo<MNewsInfo> pageRequest) {
        // TODO Auto-generated method stub
        MPagerResultVo<MNewsInfo> pagerResult = new MPagerResultVo<MNewsInfo>();
        int count = newsInfoDao.selectMNewsInfoCount(pageRequest);
        if (count > 0) {
            int begin = (pageRequest.getCurrentpage() - 1) * pageRequest.getSize();
            pageRequest.setBegin(begin);
            pageRequest.setEnd(pageRequest.getSize());
            List<MNewsInfo> list = newsInfoDao.selectMNewsInfoForPage(pageRequest);
            pagerResult.setDataInfo(list);
        }
        pagerResult.setTotalCount(count);
        return pagerResult;
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean insertMNewsInfo(MNewsInfo newsInfo) {
        newsInfo.setAddTime(new Date());
        newsInfo.setKeyId(keyIDFactory.NewKeyID(DatabaseDefinition.GJJPKRFinancialStatementDB, TableDefinition.GJJPKRFinancialStatementDB_KcpRelationshipAccountYYYY));
        return newsInfoDao.insertMNewsInfo(newsInfo);
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean updateMNewsInfo(MNewsInfo newsInfo) {
        // TODO Auto-generated method stub
        return newsInfoDao.updateMNewsInfo(newsInfo);
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean deleteMNewsInfo(MNewsInfo newsInfo) {
        // TODO Auto-generated method stub
        return newsInfoDao.deleteMNewsInfo(newsInfo);
    }

}
